<?php if (!defined('THINK_PATH')) exit();?><!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<!-- Set render engine for 360 browser -->
	<meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- HTML5 shim for IE8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <![endif]-->

	<link href="/public/simpleboot/themes/<?php echo C('SP_ADMIN_STYLE');?>/theme.min.css" rel="stylesheet">
    <link href="/public/simpleboot/css/simplebootadmin.css" rel="stylesheet">
    <link href="/public/js/artDialog/skins/default.css" rel="stylesheet" />
    <link href="/public/simpleboot/font-awesome/4.4.0/css/font-awesome.min.css"  rel="stylesheet" type="text/css">
    <style>
		form .input-order{margin-bottom: 0px;padding:3px;width:40px;}
		.table-actions{margin-top: 5px; margin-bottom: 5px;padding:0px;}
		.table-list{margin-bottom: 0px;}
	</style>
	<!--[if IE 7]>
	<link rel="stylesheet" href="/public/simpleboot/font-awesome/4.4.0/css/font-awesome-ie7.min.css">
	<![endif]-->
	<script type="text/javascript">
	//全局变量
	var GV = {
	    ROOT: "/",
	    WEB_ROOT: "/",
	    JS_ROOT: "public/js/",
	    APP:'<?php echo (MODULE_NAME); ?>'/*当前应用名*/
	};
	</script>
    <script src="/public/js/jquery.js"></script>
    <script src="/public/js/wind.js"></script>
    <script src="/public/simpleboot/bootstrap/js/bootstrap.min.js"></script>
    <script>
    	$(function(){
    		$("[data-toggle='tooltip']").tooltip();
    	});
    </script>
<?php if(APP_DEBUG): ?><style>
		#think_page_trace_open{
			z-index:9999;
		}
	</style><?php endif; ?>
<style type="text/css">
.pic-list li {
	margin-bottom: 5px;
}
</style>
<script type="text/html" id="photos-item-wrapper">
    <li id="savedimage{id}">
        <input id="photo-{id}" type="hidden" name="pictures[]" value="{filepath}">
        <input id="photo-{id}-name" type="text" name="photos_alt[]" value="{name}" style="width: 160px;" title="图片名称">
        <img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;" onclick="parent.image_preview_dialog(this.src);">
        <a href="javascript:upload_one_image('图片上传','#photo-{id}');">替换</a>
        <a href="javascript:(function(){$('#savedimage{id}').remove();})();">移除</a>
    </li>
</script>
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li><a href="<?php echo U('AdminArticle/index');?>">文章列表</a></li>
			<li class="active"><a href="<?php echo U('AdminArticle/add',array('id'=>empty($item['id'])?'':$item['id']));?>" target="_self">新增文章</a></li>
		</ul>
		<form action="<?php echo U('AdminArticle/add_post');?>" method="post" class="form-horizontal js-ajax-forms" enctype="multipart/form-data">
			<div class="row-fluid">
				<div class="span9">
					<table class="table table-bordered">
						<tr>
							<th>选择分类</th>
							<td>
                                <select name="tid">
								<?php if(is_array($type_list)): foreach($type_list as $key=>$titem): ?><option <?php if($item['tid'] == $titem['id']): ?>selected<?php endif; ?> value="<?php echo ($titem["id"]); ?>">
                                        <?php echo ($titem["title"]); ?>
                                    </option><?php endforeach; endif; ?>
                                </select>
								<span class="form-required">*</span>
							</td>
						</tr>

                        <tr>
                            <th>文章标题</th>
                            <td><input type="text" name="title" id="title" value="<?php echo ($item["title"]); ?>" style="width: 400px" placeholder="请输入文章标题"> </td>
                        </tr>

                        <tr>
                            <th>内容</th>
                            <td>
                                <script type="text/plain" id="content" name="content"><?php echo ($item["content"]); ?></script>
                            </td>
                        </tr>

                        <tr>
                            <th>排序</th>
                            <td><input type="text" name="sort" id="sort" value="<?php echo ($item["sort"]); ?>" style="width: 400px" > </td>
                        </tr>
					</table>
				</div>

			</div>
			<div class="form-actions">
                <input type="hidden" name="id" value="<?php echo ($item["id"]); ?>"/>
				<button class="btn btn-primary js-ajax-submit" type="submit">提交</button>
				<a class="btn" href="<?php echo U('AdminPost/index');?>">返回</a>
			</div>
		</form>
	</div>
	<script type="text/javascript" src="/public/js/common.js"></script>
    <script type="text/javascript">
        //编辑器路径定义
        var editorURL = GV.WEB_ROOT;
    </script>
    <script type="text/javascript" src="/public/js/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" src="/public/js/ueditor/ueditor.all.min.js"></script>
    <script type="text/javascript">
        $(function() {
            /////---------------------
            Wind.use('validate', 'ajaxForm', 'artDialog', function() {
                //javascript

                //编辑器
                editorcontent = new baidu.editor.ui.Editor();
                editorcontent.render('content');
                try {
                    editorcontent.sync();
                } catch (err) {
                }
                //增加编辑器验证规则
                jQuery.validator.addMethod('editorcontent', function() {
                    try {
                        editorcontent.sync();
                    } catch (err) {
                    }
                    return editorcontent.hasContents();
                });
                var form = $('form.js-ajax-forms');
                //ie处理placeholder提交问题
                if ($.browser && $.browser.msie) {
                    form.find('[placeholder]').each(function() {
                        var input = $(this);
                        if (input.val() == input.attr('placeholder')) {
                            input.val('');
                        }
                    });
                }

            });
            ////-------------------------
        });
    </script>
	</body>
</html>